package com.auto.survey.activity.monitoring.dao

import androidx.room.Dao
import androidx.room.Query
import androidx.room.Transaction
import com.auto.survey.activity.monitoring.entity.relations.MonitoringPointWithCtrlObserv

@Dao
interface MonitoringPointWithCtrlObservDao {
    // 根据测点ID查询测点及其所有观测数据
    @Transaction
    @Query("SELECT * FROM MonitoringPoint WHERE id = :pointId")
    suspend fun getPointWithObservations(pointId: Int): MonitoringPointWithCtrlObserv?

    // 根据监测对象ID查询所有测点及其观测数据
    @Transaction
    @Query("SELECT * FROM MonitoringPoint WHERE monitoringObjectId = :objectId")
    suspend fun getPointsWithObservationsByObjectId(objectId: Int): List<MonitoringPointWithCtrlObserv>

    // 根据站点ID查询所有测点及其观测数据
    @Transaction
    @Query("SELECT * FROM MonitoringPoint WHERE stationId = :stationId")
    suspend fun getPointsWithObservationsByStationId(stationId: Int): List<MonitoringPointWithCtrlObserv>

    // 查询所有测点及其观测数据
    @Transaction
    @Query("SELECT * FROM MonitoringPoint ORDER BY measurementOrder ASC")
    suspend fun getAllPointsWithObservations(): List<MonitoringPointWithCtrlObserv>

}